home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-MIPS / SPINLOCK.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  63 lines

  1. /* $Id: spinlock.h,v 1.3 1998/08/28 15:55:39 ralf Exp $
  2.  */
  3. #ifndef __ASM_MIPS_SPINLOCK_H
  4. #define __ASM_MIPS_SPINLOCK_H
  5.  
  6. #ifndef __SMP__
  7.  
  8. /*
  9.  * Gcc-2.7.x has a nasty bug with empty initializers.
  10.  */
  11. #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
  12.   typedef struct { } spinlock_t;
  13.   #define SPIN_LOCK_UNLOCKED { }
  14. #else
  15.   typedef struct { int gcc_is_buggy; } spinlock_t;
  16.   #define SPIN_LOCK_UNLOCKED { 0 }
  17. #endif
  18.  
  19. #define spin_lock_init(lock)    do { } while(0)
  20. #define spin_lock(lock)        do { } while(0)
  21. #define spin_trylock(lock)    (1)
  22. #define spin_unlock_wait(lock)    do { } while(0)
  23. #define spin_unlock(lock)    do { } while(0)
  24. #define spin_lock_irq(lock)    cli()
  25. #define spin_unlock_irq(lock)    sti()
  26.  
  27. #define spin_lock_irqsave(lock, flags)        save_and_cli(flags)
  28. #define spin_unlock_irqrestore(lock, flags)    restore_flags(flags)
  29.  
  30. /*
  31.  * Read-write spinlocks, allowing multiple readers
  32.  * but only one writer.
  33.  *
  34.  * NOTE! it is quite common to have readers in interrupts
  35.  * but no interrupt writers. For those circumstances we
  36.  * can "mix" irq-safe locks - any writer needs to get a
  37.  * irq-safe write-lock, but readers can get non-irqsafe
  38.  * read-locks.
  39.  */
  40. typedef struct { } rwlock_t;
  41. #define RW_LOCK_UNLOCKED { }
  42.  
  43. #define read_lock(lock)        do { } while(0)
  44. #define read_unlock(lock)    do { } while(0)
  45. #define write_lock(lock)    do { } while(0)
  46. #define write_unlock(lock)    do { } while(0)
  47. #define read_lock_irq(lock)    cli()
  48. #define read_unlock_irq(lock)    sti()
  49. #define write_lock_irq(lock)    cli()
  50. #define write_unlock_irq(lock)    sti()
  51.  
  52. #define read_lock_irqsave(lock, flags)        save_and_cli(flags)
  53. #define read_unlock_irqrestore(lock, flags)    restore_flags(flags)
  54. #define write_lock_irqsave(lock, flags)        save_and_cli(flags)
  55. #define write_unlock_irqrestore(lock, flags)    restore_flags(flags)
  56.  
  57. #else
  58.  
  59. #error "Nix SMP on MIPS"
  60.  
  61. #endif /* SMP */
  62. #endif /* __ASM_MIPS_SPINLOCK_H */
  63.